﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Example1.Tests
{
    [TestClass]
    public class RouteTests4

    {
        [TestMethod]
        public void TestMethod1()
        {
            //suppose web app has been know to have an url ending with /Shop.aspx
            // now it is replaced with /Home controller & Index actions

            RouteCollection routes = new RouteCollection();


        
            routes.MapRoute("1", "shop.aspx", new { controller = "Home", action = "Index" });
            routes.MapRoute("2", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

            RouteTestHelper.TestRouteMatch(routes, "~/shop.aspx", "Home", "index");
        }


        [TestMethod]
        public void TestMethod2()
        {
            //suppose web app has been know to have an url ending with /Shop/oldaction
            // by the newaction action

            RouteCollection routes = new RouteCollection();



            routes.MapRoute("1", "shop/oldaction", new { controller = "shop", action = "newaction" });
            routes.MapRoute("2", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });

            RouteTestHelper.TestRouteMatch(routes, "~/shop/oldaction", "Shop", "newaction");
        }
    }
}
